home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
SciAn
/
src
/
ScianDepend.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
3KB
|
159 lines
/*ScianDepend.c
Eric Pepke
May 22, 1991
Dependencies system for SciAn
*/
#include "Scian.h"
#include "ScianTypes.h"
#include "ScianIDs.h"
#include "ScianErrors.h"
#include "ScianDepend.h"
Bool mustMake = false;
static void CallBack(obj, destVar, indVar, sourceVar)
ObjPtr obj;
NameTyp destVar, indVar, sourceVar;
{
ObjPtr indObject;
if (indVar)
{
MakeVar(obj, indVar);
indObject = GetVar(obj, indVar);
if (!indObject) return;
}
else
{
indObject = obj;
}
MakeVar(indObject, sourceVar);
if (CompareVarChangeCounts(obj, destVar, indObject, sourceVar))
{
/*Yes, it needs to be made*/
#ifdef DEBUG
ObjPtr name;
char out[256];
name = GetVar(obj, NAME);
sprintf(out, "Need to make object %lx ", obj);
if (name)
{
sprintf(tempStr, "(%s) ", GetString(name));
strcat(out, tempStr);
}
sprintf(tempStr, "variable %s ", IDName(destVar));
strcat(out, tempStr);
sprintf(tempStr, "due to change in %s", IDName(sourceVar));
strcat(out, tempStr);
puts(out);
#endif
mustMake = true;
}
}
int testomatic (double);
Bool MakeVar(origObj, destVar)
ObjPtr origObj;
int destVar;
/*Makes destVar within origObj. Returns true iff it had to make it.*/
{
ObjPtr class, var;
long initialCount;
FuncTyp method;
Bool retVal = false;
Bool oldMustMake;
oldMustMake = mustMake;
mustMake = false;
initialCount = GetVarChangeCount(origObj, destVar);
GetDependencies(origObj, destVar, CallBack);
retVal = initialCount == GetVarChangeCount(origObj, destVar) ? false : true;
if (GetVarChangeCount(origObj, destVar) <= 0)
{
#ifdef DEBUG
ObjPtr name;
char out[256];
name = GetVar(origObj, NAME);
sprintf(out, "Need to make object %lx ", origObj);
if (name)
{
sprintf(tempStr, "(%s) ", GetString(name));
strcat(out, tempStr);
}
sprintf(tempStr, "variable %s ", IDName(destVar));
strcat(out, tempStr);
sprintf(tempStr, "first time");
strcat(out, tempStr);
puts(out);
#endif
mustMake = true;
}
if (mustMake)
{
/*Yes, it needs to be made*/
FuncTyp method;
#ifdef DEBUG
ObjPtr name;
char out[256];
name = GetVar(origObj, NAME);
sprintf(out, "Making object %lx ", origObj);
if (name)
{
sprintf(tempStr, "(%s) ", GetString(name));
strcat(out, tempStr);
}
sprintf(tempStr, "variable %s", IDName(destVar));
strcat(out, tempStr);
puts(out);
#endif
method = GetMethod(origObj, destVar);
if (method)
{
(*method)(origObj);
}
else
{
/*SetVar(origObj, destVar, NULLOBJ);*/
/*ReportError("MakeVar", "No make method found");*/
}
}
mustMake = oldMustMake;
return retVal;
}
void DeclareDependency(object, destVar, sourceVar)
ObjPtr object;
int destVar, sourceVar;
/*Declares a variable dependency within object of destVar on sourceVar*/
{
SetDependency(object, destVar, sourceVar);
}
void DeclareIndirectDependency(object, destVar, indirectObject, sourceVar)
ObjPtr object;
int destVar, indirectObject, sourceVar;
/*Declares a variable dependency within object of destVar on sourceVar
within object indirectObject*/
{
SetIndirectDependency(object, destVar, indirectObject, sourceVar);
}